

import 'package:flutter/material.dart';


Function alert1 = (context){
    showDialog(
        barrierDismissible: false, //表示点击灰色背景的时候是杳消失弹出框
        context: context,
        builder: (context) {
          return AlertDialog(
            title: const Text("标题"),
            content: const Text("内容"),
            actions: [
              TextButton(
                  onPressed: () {
                    // Navigator.popAndPushNamed(context, "OK");
                    Navigator.of(context).pop("确定");
                  },
                  child: const Text("确定")),
              TextButton(
                  onPressed: () {
                    // Navigator.popAndPushNamed(context, "取消");
                    Navigator.of(context).pop("取消");
                  },
                  child: const Text("取消")),
            ],
          );
        });
};




// Future<T?> showBottomSheet<T>({
//   required BuildContext context,
//   required WidgetBuilder builder
// }){
//   assert(debugCheckHasMaterialLocalizations(context));

//   final CapturedThemes themes = InheritedTheme.capture(
//     from: context,
//     to: Navigator.of(
//       context,
//     ).context,
//   );

//   return 
// }




class MyDialog extends Dialog {

  String title;
  String content;
  MyDialog({this.title = '', this.content = ''});

  @override
  Widget build(BuildContext context) {
    return Material(
        type: MaterialType.transparency,
        child: Center(
            child: Container(
                height: 300,
                width: 300,
                color: Colors.white,
                child: Column(children: [
                  Padding(
                      padding: EdgeInsets.all(20),
                      child: Stack(
                        children: <Widget>[
                          Align(
                              alignment: Alignment.center, child: Text(this.title)),
                          Align(
                            alignment: Alignment.centerRight,
                            child: InkWell(
                              child: Icon(Icons.close),
                              onTap: ()=> { Navigator.pop(context) },
                            ),
                          )
                        ],
                      )),
                  Divider(),
                  Container(
                    padding: EdgeInsets.all(10),
                    width: double.infinity,
                    child: Text('${this.content}', textAlign: TextAlign.left,),
                  )
                ]))));
  }
}


_buildCustomDialog(BuildContext context) {
    showDialog(
        context: context,
        builder: (context) {
          return MyDialog(title: '标题', content: '内容');
        });
  }